<include file="Public/common1" />
<block name="css">
    <link rel="stylesheet" type="text/css" href="__CSS__/index/order_detail.css">
    <style>
        .money{ margin-top: 15px; font-size: 16px; font-weight: bloder; }
    </style>
</block>
<block name="content">
    <div class="page-header"><h1>财务管理 &gt;营业收入报表</h1></div>
    <form id="form" action="">
        <!-- 待结算 -->
        <section class="clearfix" id="unSettlement">
            <div class="col-xs-12 clearfix mt-15">
                <div class="col-xs-6">
                    <label class="col-xs-2">下单时间</label>
                    <div class="col-xs-4"><input id="start" placeholder="开始时间" name="start_time" class="form-control" value="<if condition="$_GET['start_time']">{$_GET['start_time']}</if>"/></div>
                    <div class="col-xs-4"><input id="end" placeholder="结束时间"class="form-control"name="end_time" class="form-control" value="<if condition="$_GET['end_time']">{$_GET['end_time']}</if>" /></div>
                </div>
                <div class="col-xs-6">
                    <label class="col-xs-2">销售人</label>
                    <div class="col-xs-5">
                        <select name="reseller_id" class="form-control">
                            <option value="">全部</option>
                            <foreach name="staff" item="v">
                                <option value="{$v['reseller_id']}" <if condition="$_GET['reseller_id'] == $v['reseller_id']">selected</if>>{$v['reseller_name']}</option>
                            </foreach>
                        </select>
                    </div>
                </div>
            </div>

            <div class="col-xs-12 clearfix mt-15">
                <div class="col-xs-6">
                    <!-- <//if condition="ACTION_NAME == 'resellerList'">
                    <button type="button" id="moreBlance" class="btn btn-primary">批量审核</button>
                    </*/if*/> -->
                    <if condition="checkAuth('Reseller/Finance/exportReportToExcel')">
                        <button type="submit" class="btn btn-primary">查询</button>
                    </if>
                    <button type="button"  id="export" class="btn btn-primary mr-10">导出</button>
                </div>
                <div class="col-xs-2 money">成本：<span class="text-danger">&#165;{$orders['info']['sum(need_pay)'] | round=###,2}</span></div>
                <div class="col-xs-2 money">实收：<span class="text-danger">&#165;{$orders['info']['sum(end_need_pay)'] |round=###,2}</span></div>
                <div class="col-xs-2 money">毛利：<span class="text-danger">&#165;<php> echo round($orders['info']['sum(end_need_pay)'] - $orders['info']['sum(need_pay)'], 2)</php></span></div>
            </div>

        </section>
    </form>


    <table class="table table-striped table-bordered table-hover table-condensed  mt-15">
        <!-- <caption>营业收入</caption> -->
        <thead>
            <tr>
                <th>订单号</th>
                <th>线路名称</th>
                <th>人数</th>
                <th>实收金额</th>
                <th>成本(结算价)</th>
                <th>收款人</th>
                <th>销售员</th>
                <th>下单时间</th>
                <th>其他毛利</th>
            </tr>
        </thead>
        <tbody>
            <foreach name="orders['list']" item="v">
                <tr>
                    <td>{$v['order_num']}</td>
                    <td>{$v['line_name']}</td>
                    <td>{$v['total_num']}</td>
                    <td>{$v['end_need_pay']}</td>
                    <td>{$v['need_pay']}</td>
                    <td>{$v['payee']}</td>
                    <td>{$v['reseller_name']}</td>
                    <td>{$v['create_time'] | date='Y-m-d', ###}</td>
                    <td>{$v['end_need_pay'] - $v['need_pay']}</td>
                </tr>
            </foreach>
        </tbody>
    </table>
    <ul class="pagination pull-right">{$orders['show']}</ul>
</block>
<block name="js">
<script src="__JS__/jedate/jedate.js"></script>
<script>
var $form = $('#form');
$('#export').on('click', function(){
    $form.attr('action', '{:U('exportReportToExcel')}');
    $form.submit();
    $form.attr('action', '');
})

dateFormat($('#start'), 'YYYY-MM-DD');
dateFormat($('#end'), 'YYYY-MM-DD');

/**
 * 绑定日期选择器
 * @param  {[obj]}    obj        [元素]
 * @param  {[string]} dateFormat [时间格式]
 */
function dateFormat(obj, dateFormat){
    jeDate({
        dateCell: '#'+$(obj).attr('id'),
        format: dateFormat,
        isinitVal:false,
        isTime:true, //isClear:false,
        okfun:function(val){
        }
    });
}


</script>
</block>
